package terra.model.runnable;

import terra.managers.ThreadPoolManager;
import terra.model.World;
import terra.model.object.GameObject;

public class MapIndexChecker implements Runnable {

	GameObject object;
	int oldMapIndex;

	public MapIndexChecker(GameObject obj, int oldMapIndex) {
		object = obj;
		this.oldMapIndex = oldMapIndex;
	}

	@Override
	public void run() {
		if (object == null)
			ThreadPoolManager.getInstance().removeRunnable(this);
		if (object.getMapIndex() != oldMapIndex)
			World.objectChangeMap(object, oldMapIndex);
		object = null;
		try {
			this.finalize();
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
